import { defineStore } from "pinia";
import { reqDepartmentInfo, reqHospitalDetail } from "@/api/hospital";
import {
  hospitaldetailResponse,
  hostitaldetail,
  department,
} from "@/api/hospital/type";
const useHospitalDetailStore = defineStore("hospitalDetail", {
  state: () => {
    return {
      hospitaldetailinfo: {} as hostitaldetail,
      departmentinfo: [{}] as department[],
    };
  },
  actions: {
    //   请求医院详情
    async getHospitalDetail(hoscode: string) {
      let result = await reqHospitalDetail(hoscode);
      if (result.code == 200) this.hospitaldetailinfo = result.data;
    },
    // 请求科室信息
    async getDepartmentInfo(hoscode: string) {
      let result = await reqDepartmentInfo(hoscode);
      if ((result.code = 200)) this.departmentinfo = result.data;
    },
  },
});
export default useHospitalDetailStore;
